package com.think.admin.model.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.think.common.model.BaseModel;
import com.think.common.utils.SysUtils;
import com.think.dao.enums.ResourceTypeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xwj
 * @date 2019/3/4 9:47
 **/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class MenuTreeDTO extends BaseModel {

    /**
     * 资源名
     */
    private String name;

    /**
     * 图标
     */
    private String icon;

    /**
     * 地址
     */
    @JsonProperty("url")
    private String uri;

    /**
     * 资源类型
     */
    private ResourceTypeEnum type;

    /**
     * 序号
     */
    private Integer sort;

    /**
     * 父id
     */
    private String parentId;

    /**
     * 子级
     */
    @JsonProperty("subMenus")
    private List<MenuTreeDTO> childrenList;

    public List<MenuTreeDTO> getChildrenList() {
        if (SysUtils.isEmpty(this.childrenList)) {
            this.childrenList = new ArrayList<>();
        }
        return this.childrenList;
    }
}
